var assert = require('assert');
var should = require('should');
var util = require('util');
var zlib = require('zlib');
var _ = require('lodash');
var levelService = require('../../app/services/levelService');
var battleRewardService = require('../../app/services/battleRewardService');
var config = require('../config');
var dataApi = require('../../app/libs/dataApi');
var rewardType = require('../../app/consts/rewardType');
var equipConf = require('../../app/config/equipConf');
var propertyConf = require('../../app/config/propertyConf');

suite('测试battleRewardService', function () {
    suite('getRewardLv', function () {
        test('获取奖励的等级', function () {
            levelService.getRewardLv(0.1).should.equal(1);
            levelService.getRewardLv(1).should.equal(1);
            levelService.getRewardLv(2).should.equal(1);
            levelService.getRewardLv(4).should.equal(1);
            levelService.getRewardLv(5).should.equal(10);
            levelService.getRewardLv(9).should.equal(10);
            levelService.getRewardLv(11).should.equal(10);
            levelService.getRewardLv(15).should.equal(20);
            levelService.getRewardLv(64).should.equal(60);
            levelService.getRewardLv(67).should.equal(60);
        });
    });

    suite('getReward', function () {
        test('获取奖励的等级', function () {
            this.timeout(1000000);
            var hero_lvl_all_conf = dataApi.hero_lvl.all();
            for (var i = 0; i < 100; i++) {
                _getReward(hero_lvl_all_conf);
            };
        });
    });
});

var _getReward = function (hero_lvl_all_conf) {
    _.each(hero_lvl_all_conf, function (value, key) {
        // var reward_list = battleRewardService.getReward(key, 3);
        // _.size(reward_list).should.equal(3);
        // _.each(reward_list, function (reward_item) {
        //     var reward_type = reward_item.reward_type;
        //     var reward = reward_item.reward;
        //     var reward_num = reward_item.reward_num;
        //     var reward_value = reward_item.reward_value;
        //     switch (reward_item.reward_type) {
        //     case rewardType.GOLD:
        //         {
        //             assert.equal(reward_num > 0, true);
        //             break;
        //         }
        //     case rewardType.DIAMOND:
        //         {
        //             assert.equal(reward_num > 0, true);
        //             break;
        //         }
        //     case rewardType.PROPERTY:
        //         {
        //             assert.equal(propertyConf.getPropertyTypeConf(reward) != null, true);
        //             break;
        //         }
        //     case rewardType.GEMSTONE:
        //         {
        //             assert.equal(gemstoneConf.getGemstoneTypeConf(reward) != null, true);
        //             break;
        //         }
        //     case rewardType.EQUIP:
        //         {
        //             assert.equal(equipConf.getEquipTypeConf(reward) != null, true);
        //             break;
        //         }
        //     case rewardType.RANDOM_EQUIP:
        //         {
        //             var property_conf = propertyConf.getPropertyTypeConf(reward);
        //             assert.equal(property_conf != null, true);
        //             property_conf.type.should.equal(4);
        //             break;
        //         }
        //     case rewardType.EXP:
        //         {
        //             assert.equal(reward_num > 0, true);
        //             break;
        //         }
        //     case rewardType.DRAGON_GOLD:
        //         {
        //             assert.equal(reward_num > 0, true);
        //             break;
        //         }
        //     default:
        //         {
        //             throw new Error('error');
        //         }
        //     }
        // });
    });
};
